package cn.sc.allinpay.allfavour.business.cashiertrsdetail;

import android.os.Bundle;
import android.support.v7.widget.AppCompatButton;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.OnClick;
import cn.sc.allinpay.allfavour.R;
import cn.sc.allinpay.allfavour.base.activity.BaseActivity;
import cn.sc.allinpay.allfavour.business.common.dialog.ManagerInputPwdDialog;


/**
 * activity 交易详情
 * author：pany
 * on 2017/12/1 11:14
 */
public class CashierTransDetailActivity extends BaseActivity<CashierTransDetailContract.View, CashierTransDetailContract.Presenter>
        implements CashierTransDetailContract.View {

    @BindView(R.id.tvOrderId)
    AppCompatTextView tvOrderId;
    @BindView(R.id.tvTransTime)
    AppCompatTextView tvTransTime;
    @BindView(R.id.tvCashierName)
    AppCompatTextView tvCashierName;
    @BindView(R.id.tvGuideName)
    AppCompatTextView tvGuideName;
    @BindView(R.id.tvTransAmt)
    AppCompatTextView tvTransAmt;
    @BindView(R.id.btnPrint)
    AppCompatButton btnPrint;

    @BindView(R.id.llDiscount)
    RelativeLayout llDiscount;//折扣视图
    @BindView(R.id.tvDisState)
    AppCompatTextView tvDisState;
    @BindView(R.id.tvMemberNo)
    AppCompatTextView tvMemberNo;
    @BindView(R.id.tvDiscount)
    AppCompatTextView tvDiscount;
    @BindView(R.id.tvCoupons)
    AppCompatTextView tvCoupons;
    @BindView(R.id.llCouponInfo)
    LinearLayout llCouponInfo;
    @BindView(R.id.tvEWalletAmt)
    AppCompatTextView tvEWalletAmt;
    @BindView(R.id.btnDisVoid)
    AppCompatButton btnDisVoid;

    @BindView(R.id.llPos)
    RelativeLayout llPos;//pos消费视图
    @BindView(R.id.tvPosState)
    AppCompatTextView tvPosState;
    @BindView(R.id.tvPosAmt)
    AppCompatTextView tvPosAmt;
    @BindView(R.id.tvCashAmt)
    AppCompatTextView tvCashAmt;
    @BindView(R.id.btnPosVoid)
    AppCompatButton btnPosVoid;
    @BindView(R.id.btnPosPay)
    AppCompatButton btnPosPay;

    @Override
    protected int layoutId() {
        return R.layout.activity_cashier_trans_detail;
    }

    @Override
    protected void layoutTitle(View top, AppCompatTextView left, AppCompatTextView title, AppCompatTextView right) {
        title.setText("详情");
    }

    @Override
    protected CashierTransDetailContract.Presenter bindPresenter() {
        return new CashierTransDetailPresenter();
    }

    @Override
    protected void layoutContent(Bundle savedInstanceState) {

    }

    @Override
    public void showOrderId(String data) {
        tvOrderId.setText("订  单  号:      " + data);
    }

    @Override
    public void showTransTime(String data) {
        tvTransTime.setText("交易时间:      " + data);
    }

    @Override
    public void showCashierName(String data) {
        tvCashierName.setText("收  银  员:      " + data);
    }

    @Override
    public void showGuideName(String data) {
        tvGuideName.setText("导购:      " + data);
    }

    @Override
    public void showTransAmt(String data) {
        tvTransAmt.setText("订单金额:      " + data);
    }

    @Override
    public void showBtnPrint(int visible) {
        btnPrint.setVisibility(visible);
    }

    @Override
    public void showDiscountView(int visible) {
        llDiscount.setVisibility(visible);
    }

    @Override
    public void showDisState(String data) {
        tvDisState.setText("状        态:      " + data);
    }

    @Override
    public void showMemberNo(String data) {
        tvMemberNo.setText("会员卡号:      " + data);
    }

    @Override
    public void showDiscount(String data) {
        tvDiscount.setText("会员优惠:      " + data);
    }

    @Override
    public void showCoupons(String data) {
        tvCoupons.setText("卡        券:      " + data);
    }

    @Override
    public void addCouponView(String couponName, String couponAmt) {
        TextView textView = new TextView(this);
        textView.setTextSize(14);
        textView.setText("   " + couponName + "              " + couponAmt);
        llCouponInfo.addView(textView, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    }

    @Override
    public void showEWalletAmt(String data) {
        tvEWalletAmt.setText("电子钱包:      " + data);
    }

    @Override
    public void showBtnDisVoid(int visible) {
        btnDisVoid.setVisibility(visible);
    }

    @Override
    public void showPosView(int visible) {
        llPos.setVisibility(visible);
    }

    @Override
    public void showPosState(String data) {
        tvPosState.setText("状        态:      " + data);
    }

    @Override
    public void showPosAmt(String data) {
        tvPosAmt.setText(data);
    }

    @Override
    public void showCashAmt(String data) {
        tvCashAmt.setText(data);
    }

    @Override
    public void showBtnPosVoid(int visible) {
        btnPosVoid.setVisibility(visible);
    }

    @Override
    public void showBtnPosPay(int visible) {
        btnPosPay.setVisibility(visible);
    }

    @Override
    public void showManagerPwdDialog(ManagerInputPwdDialog.OnDialogListener listener) {
        ManagerInputPwdDialog dialog = new ManagerInputPwdDialog(this);
        dialog.setOnDialogListener(listener);
        dialog.show();
    }

    @OnClick({R.id.btnPrint, R.id.btnDisVoid, R.id.btnPosVoid, R.id.btnPosPay})
    public void btnClick(View view) {
        switch (view.getId()) {
            case R.id.btnPrint:
                presenter.callPrint();//重打印
                break;
            case R.id.btnDisVoid://抵扣撤销，先撤销积分
                presenter.reqVoidIntegral();
                break;
            case R.id.btnPosVoid://pos撤销
                presenter.callPosVoid();
                break;
            case R.id.btnPosPay://去支付
                presenter.startPaymentActivity();
                break;
        }
    }

    @Override
    public void onBackPressed() {
        presenter.setActivityForResult();
    }
}
